package ddd.ajava.chapter3.question4;

public class Animal {
	public static void main(String[] args) throws Exception {
		Zoo<Fish> fishZoo = new Zoo<Fish>(new Fish());
		Zoo<Bird> birdZoo = new Zoo<Bird>(new Bird());
		//java编译器保证对方法的访问，在类型参数擦除之前
		fishZoo.t.get1();
		boolean isSampleClass = fishZoo.getClass().equals(birdZoo.getClass());
		System.out.println("两者的类型相同：" + isSampleClass);
		System.out.println(fishZoo.getClass().getCanonicalName());
	}
}

class Bird extends Animal {
	public void get(){
		System.out.println("Bird get!");
	}
}

class Fish extends Animal {
	public void get1(){
		System.out.println("Fish get!");
	}
}

class Zoo<T> {
	public T t;

	public Zoo(T t) {
		this.t = t;
	}

	public T pop() {
		return this.t;
	}
	
	//java编译器保证对方法的访问，在类型参数擦除之前
//	public void g(){
//		((Bird) t).get();
//	}
}
